<template>
  <div>
    <router-link to="/member/AddMember"><el-button>添加</el-button></router-link>
    <el-table
      :data="memberList"
      :stripe="true"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名">
      </el-table-column>
      <el-table-column
        prop="description"
        label="描述">
      </el-table-column>
      <el-table-column
        prop="tel"
        label="电话">
      </el-table-column>
      <el-table-column
        label="性别">
        <template slot-scope="scope">
          <div v-if="scope.row.gender==0">女</div>
          <div v-if="scope.row.gender==1">男</div>
        </template>
      </el-table-column>
      <el-table-column
        prop="age"
        label="年龄">
      </el-table-column>
      <el-table-column
        prop="endDate"
        label="到期时间">
      </el-table-column>

      <el-table-column
        label="操作" width="300px">
        <template slot-scope="scope">
          <el-button @click="deleteById(scope.row.id)" size="mini">删除</el-button>
          <router-link :to="'/member/UpdateMember?id='+scope.row.id"><el-button size="mini">完善会员信息</el-button></router-link>
        </template>
      </el-table-column>
    </el-table>
    <router-view/>
  </div>
</template>

<script>
    export default {
        name: "memberList",
      data(){
          return {
            memberList:[]
          }
      },
      created(){
          this.selectAll();
      },
      methods:{
        deleteById(id){
          this.$confirm("是否确认删除","删除提示").then(()=> {
            this.axios.delete("/member/delete/" + id).then((resp) => {
              //提示保存成功信息
              this.$message.success("删除成功！");
              this.selectAll();
            });
          });
        },
        selectAll(){
          //发出ajax请求请求后端代码
          let url="/member/selectAll";
          this.axios.get(url).then((resp)=>{
            this.memberList=resp.data;
          });
        }
      }
    }
</script>

<style scoped>

</style>
